//
//  TMViewController.m
//  TMFishTravel
//
//  Created by Playboy on 2017/10/11.
//  Copyright © 2017年 tmkj. All rights reserved.
//

#import "TMViewController.h"
#import "TMTabBarViewController.h"

@interface TMViewController ()

@end

@implementation TMViewController

-(void)dealloc{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

//- (instancetype)init
//{
//    self = [super init];
//    if (self) {
//        [self resetTabBar];
//    }
//    return self;
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self resetNavigationBarItems];
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    // 添加手势返回
    self.navigationController.interactivePopGestureRecognizer.enabled=YES;
    self.navigationController.interactivePopGestureRecognizer.delegate=(id<UIGestureRecognizerDelegate>)self;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init]
//                                                  forBarMetrics:UIBarMetricsDefault];
//    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc]init]];
    [self resetNavigationBar];
    [self resetNavigationAndTabBar];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.view endEditing:YES];
}

- (void)resetNavigationBarItems {
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"backButton"] style:UIBarButtonItemStylePlain target:self action:@selector(backBarButtonItemClick:)];
    self.navigationItem.leftBarButtonItem = backItem;
}

- (void)resetNavigationBar {

    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)resetNavigationAndTabBar {
    
//    UINavigationBar *navigationBar = self.navigationController.navigationBar;
//    [navigationBar setBackgroundImage:[UIImage new]
//                       forBarPosition:UIBarPositionAny
//                           barMetrics:UIBarMetricsDefault];
//    [navigationBar setShadowImage:[UIImage new]];
}

- (void)resetTabBar {
    self.hidesBottomBarWhenPushed = YES;
}

- (void)backBarButtonItemClick:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
